//
//  MeUserInfoCell.m
//  youthNote
//
//  Created by huangrensheng on 16/6/14.
//  Copyright © 2016年 laber. All rights reserved.
//

#import "MeUserInfoCell.h"

@interface MeUserInfoCell()
@property (nonatomic , strong) UIImageView *iconImage;
@property (nonatomic , strong) UILabel *userName;
@end

@implementation MeUserInfoCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.contentView.layer.contents = (id)[UIImage imageNamed:@"me_user_back"].CGImage;
        [self initChildViews];
        [self makeConstraints];
    }
    return self;
}

- (void)initChildViews{
    self.iconImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"user_default_icon"]];
    self.iconImage.backgroundColor = [UIColor whiteColor];
    self.iconImage.layer.cornerRadius = 60;
    self.layer.masksToBounds = YES;
    self.layer.borderColor = [UIColor clearColor].CGColor;
    self.layer.borderWidth = 1.0f;
    [self.contentView addSubview:self.iconImage];
    
    self.userName = [[UILabel alloc] initWithFont:[UIFont boldSystemFontOfSize:18] TextColor:DARK_GRAY_COLOR Text:@"登录"];
    [self.contentView addSubview:self.userName];
    
}

- (void)makeConstraints{
    __weak typeof(self) weakSelf = self;
    [self.iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(weakSelf.contentView.mas_centerX);
        make.top.equalTo(weakSelf.contentView.mas_top).equalTo(inset(20));
        make.width.equalTo(inset(120));
        make.height.equalTo(inset(120));
    }];
    
    [self.userName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(weakSelf.contentView.mas_centerX);
        make.top.equalTo(weakSelf.iconImage.mas_bottom).equalTo(inset(25));
    }];
}

- (void)setCellData:(NSDictionary *)cellData{
    if (cellData == nil) {
        self.userName.text = @"登录";
        return;
    }
    super.cellData = cellData;
    self.userName.text = cellData[@"userName"];
}

@end
